/**
 * JLego Validator Library
 */
OREG.Validator = function(){
	
}
OREG.Validator.prototype = {
	errors: [],
	required: function(componentId, friendlyName){
		if(AJS.$(componentId).val().toString().trim()==''){
			// RaiseError
			this.errors.push({ message: friendlyName + ' is required' , type: 'required' });
		}
	},
    isError: function(){
    	if(this.errors.length>0) return true;
    	return false;
    },
    reset: function(){
    	this.errors = [];
    }
}

OREG.errorsToString = function(errors){
	var temp = '';
	AJS.$.each(errors,function(index,item){
		temp += '<li>'+item.message+'</li>';
	});
	return temp;
} 